package com.x.general;

import com.x.dictionary.service.Dictionary;

import java.util.SortedMap;
import java.util.TreeMap;

/**
 * 公共字典-服务提供者
 *
 * @author xulihua
 * @date 2021/9/8 17:40
 */
public class GeneralDictionary implements Dictionary {
    /**
     * 字典存储的内容
     */
    private final SortedMap<String, String> map = new TreeMap<>();

    /**
     * 构造时即创建字典内容
     */
    public GeneralDictionary() {
        map.put(
                "book",
                "a set of written or printed pages, usually bound with " +
                        "a protective cover");
        map.put(
                "editor",
                "a person who edits");
    }

    @Override
    public String name() {
        return "GeneralDictionary";
    }

    @Override
    public String getDefinition(String word) {
        return map.get(word);
    }
}
